home *** CD-ROM | disk | FTP | other *** search
- (*---------------------------------------------------------------------------*)
- (* Display_Screen -- Display formatted screen *)
- (*---------------------------------------------------------------------------*)
-
- PROCEDURE Display_Screen;
-
- (*---------------------------------------------------------------------------*)
- (* *)
- (* Routine: Display_Screen *)
- (* *)
- (* Purpose: Displays formatted screen *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Display_Screen; *)
- (* *)
- (* Calls: *)
- (* *)
- (* Read_Line *)
- (* Format_Line *)
- (* Move *)
- (* Window *)
- (* InsLine *)
- (* DelLine *)
- (* GoToXY *)
- (* *)
- (* Remarks: *)
- (* *)
- (* On entry Eod=FALSE if the viewing window contains at least one *)
- (* line. In this case top points to the first line in the window. *)
- (* On exit bot points to the last Line in the window, and top_line *)
- (* is equal to the Line number of the top Line in the window. If *)
- (* the viewing window extends beyond the end of the file then the *)
- (* extra Line <End of file> is displayed. *)
- (* *)
- (* On entry Eod=TRUE if the viewing window is beyond the end of the *)
- (* file. In this case top points to the last line in the buffer, *)
- (* which is the last line in the file. Only the message *)
- (* <End of file> is displayed. On exit bot=top and top_line is *)
- (* the line number of the last line in the file plus 1. *)
- (* The <END of file> message is considered in this case *)
- (* to be an "extra" line on the file with line number Max_line+1. *)
- (* This gives proper behavior on subsequent backwards line and screen *)
- (* skipping commands. *)
- (* *)
- (* Note: Requests for 1 line up or down scrolls are handled *)
- (* as special cases. *)
- (* *)
- (*---------------------------------------------------------------------------*)
-
- VAR
- n: INTEGER;
- LineNo: INTEGER;
- ReDraw: BOOLEAN;
-
- BEGIN (* Display_Screen *)
-
- Window( 1 , 1 , 80 , 24 );
-
- bot := top;
- n := Height;
- LineNo := 0;
- One_Up := One_Up AND ( Top^.Lnum <> 1 );
-
- (* Redraw is TRUE to redraw entire *)
- (* screen. *)
-
- ReDraw := NOT ( One_Up OR One_Down );
-
- IF Eod THEN
- top_line := Top^.Lnum + 1
- ELSE
- top_line := Top^.Lnum;
-
- (* Case one: scroll screen down 1 line *)
- IF One_Up THEN
- BEGIN
- GoToXY( 1 , 1 );
- InsLine;
- Format_Line( Bot^.Txt, 1 );
- Move( My_Screen, Real_Screen^, 160 );
- WHILE ( n > 0 ) AND ( NOT Eod ) DO
- BEGIN
- LineNo := LineNo + 1;
- n := n - 1;
- IF n > 0 THEN
- IF bot = last THEN
- BEGIN
- Read_Line;
- Eod := eof(f);
- bot := last;
- END
- ELSE
- bot := Bot^.next;
- END;
- END
- (* Case 2: Scroll screen up 1 line *)
- ELSE IF One_Down THEN
- BEGIN
- GoToXY( 1 , 1 );
- DelLine;
- WHILE ( n > 0 ) AND ( NOT Eod ) DO
- BEGIN
- LineNo := LineNo + 1;
- n := n - 1;
- IF n > 0 THEN
- IF bot = last THEN
- BEGIN
- Read_Line;
- Eod := eof(f);
- bot := last;
- END
- ELSE
- bot := Bot^.next;
- END;
-
- IF n <= 0 THEN
- BEGIN
- Format_Line( Bot^.Txt, LineNo );
- GoToXY( 1 , LineNo );
- Move( My_Screen[ ( LineNo - 1 ) * 160 + 1 ],
- Real_Screen^[ ( LineNo - 1 ) * 160 + 1 ], 160 );
- END
- ELSE
- BEGIN
- LineNo := LineNo + 1;
- GoToXY( 1 , LineNo );
- WRITE( '<End of File>' );
- n := n - 1;
- END;
- END
- (* Case 3: Everything else *)
- ELSE
- BEGIN
- WHILE ( n > 0 ) AND ( NOT Eod ) DO
- BEGIN
- LineNo := LineNo + 1;
- Format_Line( Bot^.Txt, LineNo );
- n := n - 1;
- IF n > 0 THEN
- IF bot = last THEN
- BEGIN
- Read_Line;
- Eod := eof(f);
- bot := last
- END
- ELSE
- bot := Bot^.next;
- END;
-
- IF n > 0 THEN
- BEGIN
- LineNo := LineNo + 1;
- Format_Line( '<End of File>', LineNo );
- n := n - 1;
- END;
-
- WHILE( n > 0 ) DO
- BEGIN
- LineNo := LineNo + 1;
- Format_Line( ' ', LineNo );
- n := n - 1;
- END;
-
- (* Update screen memory *)
-
- Move( My_Screen, Real_Screen^, Screen_Size );
-
- END;
-
- END (* Display_Screen *);